const args=process.argv.slice(2)

//提示
function showHellp(){
    console.log("----示例说明----");
    console.log('node node-calc.js "2*3" ')
    console.log('node node-calc.js "(10+1)/2"')
}

function count(){
    try{
        const result=new Function('return'+expresstion)();
        if(typeof result!=="number"||isNaN(result)){
            return "错误"
        }
        return result;
    }catch(error){
        return "错误"
    }
}



if(args.length===0||args[0]==='help'||args[0]==='-h'){
    showHellp();
}else{
    const expresstion=args[0].trim();
    if(expresstion===''){
        console.log("打印不能为空");
        showHellp();
    }else{
        const result=count(expresstion);
        console.log("运算结果为"+result);
    }
}